# 源文件路径
file(GLOB SERVER_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/server/*.cc)
file(GLOB CLIENT_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/client/*.cc)
file(GLOB PROTO_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/proto/*.cc)

# 需要链接的库文件
set(LIBS
    sRpc
    protobuf
    pthread
    zookeeper_mt
    muduo_net
    muduo_base
    glog
)

add_executable(server ${PROTO_SRCS}  ${SERVER_SRCS} )
target_link_directories(server PRIVATE ${CMAKE_SOURCE_DIR}/../lib)
target_link_libraries(server PRIVATE ${LIBS})

file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)

add_custom_command(
    TARGET server
    POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:server> ${CMAKE_CURRENT_SOURCE_DIR}/bin/
    COMMENT ""
    VERBATIM
)

add_executable(client  ${PROTO_SRCS} ${CLIENT_SRCS})
target_link_directories(client PRIVATE ${CMAKE_SOURCE_DIR}/../lib)
target_link_libraries(client PRIVATE ${LIBS})

add_custom_command(
    TARGET client
    POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:client> ${CMAKE_CURRENT_SOURCE_DIR}/bin/
    COMMENT ""
    VERBATIM
)

